import { IDoctorList } from '@/types/doctor.type'
import { defineStore } from 'pinia'
import { reactive, ref } from 'vue'
import { listDoctorReq } from '@/api/doctor.api';


export const useDoctorStore = defineStore('doctor', () => {
    // 请求的页数
    const pageInfo = reactive({
        page: 1,
        size: 10
    })
    // 总条数
    const total = ref(0)

    // 保存请求后的结果
    let doctorList = reactive<{ list: IDoctorList[] }>({
        list: []
    })
    listDoctorReq(pageInfo.page, pageInfo.size).then(res => {
        doctorList.list = res.data.data
        total.value = res.data.total as number
    })
    return {
        doctorList,
        pageInfo,
        total,
        listDoctorReq
    }
})